// vue.config.js
const TransformPages = require('uni-read-pages')


const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')

const {
	webpack
} = new TransformPages()
module.exports = {
	configureWebpack: {
		plugins: [
			new webpack.DefinePlugin({
				ROUTES: webpack.DefinePlugin.runtimeValue(() => {
					const tfPages = new TransformPages({
						includes: ['path', 'name', 'aliasPath', 'meta']
					});
					return JSON.stringify(tfPages.routes)
				}, true)
			}),
			new CopyWebpackPlugin([{
				from: path.join(__dirname, 'node_modules'),
				to: path.join(__dirname, 'unpackage/dist', process.env.NODE_ENV === 'development' ?
					'dev' : 'build', process.env.UNI_PLATFORM, 'node_modules')
			}])
		]
	}
}